unit uOptionForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TOptionForm = class(TForm)
    Label1: TLabel;
    edtTaskCount: TEdit;
    cbShowProcess: TCheckBox;
    cbDelFinishFile: TCheckBox;
    Label2: TLabel;
    edtConverterParm_pic: TEdit;
    Label3: TLabel;
    edtSrcFilePath: TEdit;
    Label4: TLabel;
    edtPrefixpath: TEdit;
    Label5: TLabel;
    edtConverterParm: TEdit;
    Button1: TButton;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    procedure LoadConfig;
    procedure SaveConfig;
  public
    { Public declarations }
  end;

var
  OptionForm: TOptionForm;

implementation

{$R *.dfm}

uses
  IniFiles;

procedure TOptionForm.LoadConfig;
var
  iniFile: TIniFile;
begin
  iniFile := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'setup.ini');
  edtPrefixpath.Text := iniFile.ReadString('ConverterMain', 'Prefixpath', '');
  edtSrcFilePath.Text := iniFile.ReadString('ConverterMain', 'SrcFilePath', '');
  edtTaskCount.Text := iniFile.ReadString('ConverterMain', 'TaskCount', '6');
  edtConverterParm_pic.Text := iniFile.ReadString('ConverterMain', 'ConverterParm_pic', '');
  edtConverterParm.Text := iniFile.ReadString('ConverterMain', 'ConverterParm', '');
  cbDelFinishFile.Checked := iniFile.ReadBool('ConverterMain', 'DelFinishFile', False);
  cbShowProcess.Checked := iniFile.ReadBool('ConverterMain', 'ShowProcess', False);
  iniFile.Free;
end;

procedure TOptionForm.SaveConfig;
var
  iniFile: TIniFile;
begin
  iniFile := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'setup.ini');
  iniFile.WriteString('ConverterMain', 'Prefixpath', edtPrefixpath.Text);
  iniFile.WriteString('ConverterMain', 'SrcFilePath', edtSrcFilePath.Text);
  iniFile.WriteString('ConverterMain', 'TaskCount', edtTaskCount.Text);
  iniFile.WriteString('ConverterMain', 'ConverterParm_pic', edtConverterParm_pic.Text);
  iniFile.WriteString('ConverterMain', 'ConverterParm', edtConverterParm.Text);
  iniFile.WriteBool('ConverterMain', 'DelFinishFile', cbDelFinishFile.Checked);
  iniFile.WriteBool('ConverterMain', 'ShowProcess', cbShowProcess.Checked);  
  iniFile.Free;
end;

procedure TOptionForm.FormCreate(Sender: TObject);
begin
  LoadConfig;
end;

procedure TOptionForm.Button1Click(Sender: TObject);
begin
  SaveConfig;
  ModalResult := mrOk;
end;

end.
